import Cookies from 'js-cookie';

const app = {
  state: {
    sidebar: {
      opened: !+Cookies.get('sidebarStatus')
    },
    addTrigger: false,
    breadcrumb: []
  },
  mutations: {
    TOGGLE_SIDEBAR: state => {
      if (state.sidebar.opened) {
        Cookies.set('sidebarStatus', 1);
      } else {
        Cookies.set('sidebarStatus', 0);
      }
      state.sidebar.opened = !state.sidebar.opened;
    },
    BATCH_DEPLOYMENT: (state, data) => {
      state.batchDeployment = data;
    },
    ADD_TRIGGER: (state, data) => {
      state.addTrigger = data;
      if (data === false) {
        state.batchDeployment = false;
      }
    }

  },
  actions: {
    ToggleSideBar: ({commit}) => {
      commit('TOGGLE_SIDEBAR');
    }
  }
};

export default app;
